Replication materials for "Economic Evaluations and Partisan Faultfinding: When are Americans Most Likely to Answer Survey Questions Honestly?".
Author: James Bisbee (james.h.bisbee@vanderbilt.edu)
		Jan Zilinsky
		
This zipped folder is designed to reproduce all figures and tables from the manuscript and supporting information.

It contains the following directories:
	- code/: folder containing all scripts necessary to reproduce the results
		- LOG/: folder containing log files recording most recent run of the scripts on December 24, 2024
		- NFR/: folder containing scripts that process and analyze the proprietary raw Gallup data, which is not available for replication. See **NOTE** below.
	- data/: folder containing all data
		- VIMP_ranger/: folder containing results from variable importance calculated via permutation tests using a random forest
		- VIMP_lasso/: folder containing results from variable importance calculated via LASSO regression
		- PDP_models/: folder containing partial dependence results from random forest models
	- figures/: folder containing PDFs of all figure found in the manuscript and SI

The folder is designed to reproduce all output via a master R script (0_master.R). Fully replicating all content (ignoring scripts that require API keys) takes approximately 2 hours and 45 minutes on a Windows 11 laptop with a 20 core i9-13900H CPU and 17179869184 bytes of RAM.

Details on the compute environments and package versions used in the December 24, 2024 run can be found in each _LOG.txt file.

**NOTE**: provided replication materials do not include anlaysis of original raw data provided by Gallup and not to be shared publicly. These analyses were run on NYU's Greene high performance computing cluster. The scripts that generate the input data for the replication materials are included in the ./code/NFR/ folder for reference.

All contents are described in detail below. 

- code/:
	- 0_master.R: This script runs all subsequent scripts and records their output to a log file.
	- fig1.R
		################################################################################
		##
		## Date:    2024-12-20
		## Author:  james.h.bisbee@vanderbilt.edu
		## Purpose: This script generates Figure 1.
		## Inputs:  /scratch/jhb362/zilinsky_2023/data/results/VIMP_ranger/VIMP_2024.*-months.*FALSE_temp-chg12.RData
		##            - Variable importance results generated by NFR_vimp_prep.R
		##            - Summarized on the NYU HPC into PSRM_simple_months_chg12.RData via NFR_data_prep.R
		## Outputs: ./figures/fig1.pdf
		##
		## See associated log file for compute environment, package versions, 
		##  and date of most recent run.
		##
		################################################################################

	- fig2.R
		################################################################################
		##
		## Date:    2024-12-20
		## Author:  james.h.bisbee@vanderbilt.edu
		## Purpose: This script generates Figure 2.
		## Inputs:  /scratch/jhb362/zilinsky_2023/data/results/VIMP_ranger/VIMP_2024.*-months.*FALSE_temp-chg12.RData
		##            - Variable importance results generated by NFR_vimp_prep.R
		##            - Summarized on the NYU HPC into PSRM_simple_months_chg12.RData via NFR_data_prep.R
		## Outputs: ./figures/fig2.pdf
		##
		## See associated log file for compute environment, package versions, 
		##  and date of most recent run.
		##
		################################################################################
		
	- fig3.R
		################################################################################
		##
		## Date:    2024-12-20
		## Author:  james.h.bisbee@vanderbilt.edu
		## Purpose: This script generates Figure 3.
		## Inputs:  ./data/anonymized_fig3.RData
		##            - Anonymized Gallup daily data.
		## Outputs: ./figures/fig3.pdf
		##
		## See associated log file for compute environment, package versions, 
		##  and date of most recent run.
		##
		################################################################################
		
	- fig4.R
		################################################################################
		##
		## Date:    2024-12-20
		## Author:  james.h.bisbee@vanderbilt.edu
		## Purpose: This script generates Figure 4.
		## Inputs:  /scratch/jhb362/zilinsky_2023/data/results/VIMP_PDP/RF_2024_outcome.*-month.*lag1.RData
		##            - Partial dependence estimates from random forest, estimated with NFR_pdp_prep.R
		##            - Summarized on the NYU HPC into combined_res.RData via NFR_data_prep.R
		## Outputs: ./figures/fig4.pdf
		##
		## See associated log file for compute environment, package versions, 
		##  and date of most recent run.
		##
		################################################################################
		
	- fig5.R
		################################################################################
		##
		## Date:    2024-12-20
		## Author:  james.h.bisbee@vanderbilt.edu
		## Purpose: This script generates Figure 5.
		## Inputs:  /scratch/jhb362/zilinsky_2023/data/results/VIMP_ranger/VIMP_2024_outcome-.*(ECON|ENOUGHMON).*-months.*FALSE_temp-chg12.RData
		##            - Variable importance results generated by NFR_vimp_prep.R
		##            - Summarized on the NYU HPC into PSRM_comb_months_ECON_ENOUGHMON.RData via NFR_data_prep.R
		## Outputs: ./figures/fig5.pdf
		##
		## See associated log file for compute environment, package versions, 
		##  and date of most recent run.
		##
		################################################################################

	- fig6.R
		################################################################################
		##
		## Date:    2024-12-20
		## Author:  james.h.bisbee@vanderbilt.edu
		## Purpose: This script generates Figure 6.
		## Inputs:  /scratch/jhb362/zilinsky_2023/data/results/VIMP_ranger/VIMP_2024_outcome-.*(CUTBACKSPEND|MON|FEEL|SPEND).*-months.*_DumFacts-FALSE_temp-chg12
		##            - Variable importance results generated by NFR_vimp_prep.R
		##            - Summarized on the NYU HPC into PSRM_design_subset.RData via NFR_data_prep.R
		## Outputs: ./figures/fig6.pdf
		##
		## See associated log file for compute environment, package versions, 
		##  and date of most recent run.
		##
		################################################################################
		
	- figS1.R
		################################################################################
		##
		## Date:    2024-12-20
		## Author:  james.h.bisbee@vanderbilt.edu
		## Purpose: This script generates SI Figure 1.
		## Inputs:  ./data/VIMP_lasso/LASSO_2024_outcome-SOLSAT_period-years_temp-chg12.RData
		##          ./data/VIMP_lasso/LASSO_2024_outcome-ECON_period-years_temp-chg12.RData
		##            - LASSO results generated by NFR_lasso_prep.R
		## Outputs: ./figures/figS1.pdf
		##
		## See associated log file for compute environment, package versions, 
		##  and date of most recent run.
		##
		################################################################################
		
	- figS2.R
		################################################################################
		##
		## Date:    2024-12-20
		## Author:  james.h.bisbee@vanderbilt.edu
		## Purpose: This script generates SI Figure 2.
		## Inputs:  /scratch/jhb362/zilinsky_2023/data/results/VIMP_lasso/LASSO_2024_outcome-.*_period-years_temp-lag12.RData
		##            - Variable importance results generated by NFR_lasso_prep.R
		##            - Summarized on the NYU HPC into PSRM_lasso_comb.RData via NFR_data_prep.R
		## Outputs: ./figures/figS2.pdf
		##
		## See associated log file for compute environment, package versions, 
		##  and date of most recent run.
		##
		################################################################################
		
	- figS3.R
		################################################################################
		##
		## Date:    2024-12-22
		## Author:  james.h.bisbee@vanderbilt.edu; zilinsky@nyu.edu
		## Purpose: This script generates SI Figure 3.
		## Inputs:  ./data/anonymized_figS3.RData
		##            - Anonymized Gallup data
		## Outputs: ./figures/figS3.pdf
		##
		## See associated log file for compute environment, package versions, 
		##  and date of most recent run.
		##
		################################################################################
		
	- figS4.R
		################################################################################
		##
		## Date:    2024-12-22
		## Author:  james.h.bisbee@vanderbilt.edu
		## Purpose: This script generates SI Figure 4.
		## Inputs:  /scratch/jhb362/zilinsky_2023/data/results/VIMP_ranger/VIMP_2024_outcome-.*(CUTBACKSPEND|MON|FEEL|SPEND).*-weeks.*_DumFacts-FALSE_temp-chg12.RData
		##            - Variable importance results generated by NFR_vimp_prep.R
		##            - Summarized on the NYU HPC into PSRM_comb_weeks_chg12.RData via NFR_data_prep.R
		## Outputs: ./figures/figS4.pdf
		##
		## See associated log file for compute environment, package versions, 
		##  and date of most recent run.
		##
		################################################################################
		
	- figS5.R
		################################################################################
		##
		## Date:    2024-12-22
		## Author:  james.h.bisbee@vanderbilt.edu
		## Purpose: This script generates SI Figure 5.
		## Inputs:  /scratch/jhb362/zilinsky_2023/data/results/VIMP_ranger/VIMP_2024_outcome-.*(CUTBACKSPEND|MON|FEEL|SPEND).*-days.*_DumFacts-FALSE_temp-chg12.RData
		##            - Variable importance results generated by NFR_vimp_prep.R
		##            - Summarized on the NYU HPC into PSRM_comb_days_chg12_small.RData via NFR_data_prep.R
		## Outputs: ./figures/figS5.pdf
		##
		## See associated log file for compute environment, package versions, 
		##  and date of most recent run.
		##
		################################################################################
		
	- figS6.R
		################################################################################
		##
		## Date:    2024-12-22
		## Author:  james.h.bisbee@vanderbilt.edu
		## Purpose: This script generates SI Figure 6.
		## Inputs:  /scratch/jhb362/zilinsky_2023/data/results/VIMP_ranger/VIMP_2024_outcome-.*(CUTBACKSPEND|MON|FEEL|SPEND).*-weeks.*_DumFacts-FALSE_temp-chg12.RData
		##            - Variable importance results generated by NFR_vimp_prep.R
		##            - Summarized on the NYU HPC into PSRM_design_subset.RData via NFR_data_prep.R
		## Outputs: ./figures/figS6.pdf
		## Notes:   For this to run, JAGS version 4 is required.
		##
		## See associated log file for compute environment, package versions, 
		##  and date of most recent run.
		##
		################################################################################	
		
	- figS7.R
		################################################################################
		##
		## Date:    2024-12-22
		## Author:  james.h.bisbee@vanderbilt.edu
		## Purpose: This script generates SI Figure 7.
		## Inputs:  /scratch/jhb362/zilinsky_2023/data/results/VIMP_ranger/VIMP_2024_outcome-.*(CUTBACKSPEND|MON|FEEL|SPEND).*-weeks.*_DumFacts-FALSE_temp-chg12.RData
		##            - Variable importance results generated by NFR_vimp_prep.R
		##            - Summarized on the NYU HPC into PSRM_comb_weeks_chg12.RData via NFR_data_prep.R
		## Outputs: ./figures/figS7.pdf
		## Notes:   For this to run, JAGS version 4 is required.
		##
		## See associated log file for compute environment, package versions, 
		##  and date of most recent run.
		##
		################################################################################	
		
	- figS8.R
		################################################################################
		##
		## Date:    2024-12-22
		## Author:  james.h.bisbee@vanderbilt.edu
		## Purpose: This script generates SI Figure 8.
		## Inputs:  /scratch/jhb362/zilinsky_2023/data/results/VIMP_ranger/VIMP_2024_outcome-.*(CUTBACKSPEND|MON|FEEL|SPEND).*-weeks.*_DumFacts-FALSE_temp-chg12.RData
		##            - Variable importance results generated by NFR_vimp_prep.R
		##            - Summarized on the NYU HPC into PSRM_comb_days_chg12_small.RData via NFR_data_prep.R
		## Outputs: ./figures/figS8.pdf
		## Notes:   For this to run, JAGS version 4 is required.
		##
		## See associated log file for compute environment, package versions, 
		##  and date of most recent run.
		##
		################################################################################		
		
	- NFR/
		- NFR_vimp_prep.R: 
			Not For Replication. Code run on proprietary Gallup data to generate 100 bootstrapped variable importance estimates via permutation tests on a random forest model. Command line arguments allow the code to be run in parallel on the NYU Greene computing cluster. Arguments include:
				- bsInd: bootstrap index
				- per: period of aggregation (days, weeks, months, quarters, years)
				- dummy: whether to dummy out categorical predictors or treat them as continuous
				- temp: temporal transformation to apply to predictors (12 month lag, 12 month change)
			Code loops over all outcome measures of interest (variable Y). Output file naming convention: paste0('./results/VIMP_ranger/VIMP_2024_outcome-',Y,'_period-',per,'_bsInd-',bsInd,'_DumFacts-',dummy,'_temp-',temp,'.RData')
		- NRF_pdp_prep.R:
			Not For Replication. Code run on proprietary Gallup data to generate partial dependence estimated from a random forest model. Command line arguments allow the code to be run in parallel on the NYU Greene computing cluster. Arguments include:
				- args[1] / temp: period of aggregation (days, weeks, months, quarters, years)
				- args[2]: temporal transformation to apply to predictors (12 month lag, 12 month change)
			Code loops over all outcome measures of interest (variable Y). Output file naming convention: paste0('./results/PDP_models/RF_2024_outcome-',Y,'_periodUnit-',args[1],'_period-',d,'_temp-',args[2],'.RData')
		- NFR_lasso_prep.R: 
			Not For Replication. Code run on proprietary Gallup data to generate LASSO estimates of variable importance. Command line arguments allow the code to be run in parallel on the NYU Greene computing cluster. Arguments include:
				- args[1] / out: outcome variable to model
				- args[2]: period of aggregation (days, weeks, months, quarters, years)
				- args[3] / temp: temporal transformation to apply to predictors (12 month lag, 12 month change)
			Code loops over all periods (variable d). Output file naming convention: paste0('./results/VIMP_lasso/LASSO_2024_outcome-',Y,'_period-',args[2],'_temp-',args[3],'.RData')
		- NFR_data_prep.R: 
			Not For Replication (although just to save time and space). Summarizes and saves as smaller data:
				- Bootstrapped variable importance results generated by NFR_vimp_prep.R
				- Partial dependence results generated by NFR_pdp_prep.R
				- LASSO results generated by NFR_lasso_prep.R
- data/: 
	- anonymized_fig3.RData: anonymized version of proprietary Gallup data used to generate Figure 3 via fig3.R script
	- anonymized_figS3.RData: anonymized version of proprietary Gallup data used to generate Figure S3 via figS3.R script
	- PDP_models/
		- combined_res.RData: aggregate partial dependence results generated by NFR_pdp_prep.R script and aggregated by NFR_data_prep.R script
	- VIMP_lasso/
		- LASSO_2024_outcome-ECON_period-years_temp-chg12.RData: raw LASSO results generated by NFR_lasso_prep.R script
		- LASSO_2024_outcome-SOLSAT_period-years_temp-chg12.RData: raw LASSO results generated by NFR_lasso_prep.R script
		- PSRM_lasso_comb.RData: aggregate LASSO results generated by NFR_lasso_prep.R script and aggregated by NFR_data_prep.R script
	- VIMP_ranger/
		- PSRM_comb_days_chg12_small.RData: aggregate variable importance results generated by NFR_vimp_prep.R script and aggregated by NFR_data_prep.R script. (Additional simplification required to meet Dataverse size limits.)
		- PSRM_comb_weeks_chg12.RData: aggregate variable importance results generated by NFR_vimp_prep.R script and aggregated by NFR_data_prep.R script
		- PSRM_comb_months_chg12.RData: aggregate variable importance results generated by NFR_vimp_prep.R script and aggregated by NFR_data_prep.R script
		- PSRM_comb_months_ECON_ENOUGHMON.RData: aggregate variable importance results generated by NFR_vimp_prep.R script and aggregated by NFR_data_prep.R script
		- PSRM_simple_months_chg12.RData: aggregate variable importance results generated by NFR_vimp_prep.R script and aggregated by NFR_data_prep.R script
		- PSRM_design_subset.RData: aggregate variable importance results generated by NFR_vimp_prep.R script and aggregated by NFR_data_prep.R script